package com.feng.controller;

import com.feng.dto.LoginUser;
import com.feng.dto.Result;
import com.feng.service.GoodService;
import com.feng.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/good")
public class GoodController {

    @Autowired
    GoodService goodService;

    @GetMapping("/get3RandGood")
    public Result get3RandGood(){
        return goodService.getRandGood();
    }
    @GetMapping("/getSearchGood")
    public Result getSearchGood(@PathVariable("searchName") String searchName){
        return goodService.getSearchGood(searchName);
    }
    @GetMapping("/getAll")
    public Result getAll(){
        return goodService.getAll();
    }
    /*
    map包括good除了tagId的所有属性和tagName跟他的前一个tag的id
     */
    @PostMapping("/create")
    public Result create(@RequestBody Map<String,Object> map, LoginUser loginUser){
        return goodService.create(map,loginUser.getId());
    }
}
